import * as API from "../api";
import Base from "./base";

class Acticle extends Base {
  get state() {
    return {
      acticleList: [],
      currentActicle: null
    };
  }
  get actions() {
    return {
      Acticle_LIST_ACTION: async store => {
        let result = await this.get(API.ACTICLES);
        store.commit("Acticle_LIST_COMMIT", result.data);
      },
      Acticle_ITEM_ACTION: async (store, payload) => {
        let result = await this.get(API.ACTICLE + '/' + payload.id);
        store.commit("Acticle_ITEM_COMMIT", result.data);
      }
    };
  }
  get mutations() {
    return {
      Acticle_LIST_COMMIT(state, payload) {
        state.acticleList = payload;
      },
      Acticle_ITEM_COMMIT(state, payload) {
        state.currentActicle = payload;
      }
    };
  }
  get getters() {
    return {
      acticleList: state => state.acticleList
    };
  }
}

export default new Acticle();
